package com.ztsoft.user.utils;

import lombok.extern.slf4j.Slf4j;

import java.util.Calendar;
import java.util.Date;

@Slf4j
public class StringTimeUtil {
    private StringTimeUtil() {
    }

    public static String stringTime(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);                    //放入Date类型数据
        String abc = "" + calendar.get(Calendar.YEAR);
        if ((1 + calendar.get(Calendar.MONTH)) < 10) {
            abc = abc + "0";
        }
        abc += (1 + calendar.get(Calendar.MONTH));
        if (calendar.get(Calendar.DATE) < 10) {
            abc += "0";
        }
        abc += calendar.get(Calendar.DATE);
        if (date.getHours() < 10) {
            abc += "0";
        }
        abc += date.getHours();
        if (date.getMinutes() < 10) {
            abc += "0";
        }
        abc += date.getMinutes();
        if (date.getSeconds() < 10) {
            abc += "0";
        }
        abc += date.getSeconds();
        return abc;
    }
}
